﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace WODPL.GameComponents
{
    public class MouseCursor : DrawableGameComponent
    {
        private SpriteBatch MouseBatch;
        private Texture2D MouseTexture;
        private Vector2 MousePosition;

        public MouseCursor(Game game) : base(game)
        {
        }

        protected override void LoadContent()
        {
            MouseBatch = new SpriteBatch(Game.GraphicsDevice);
            MouseTexture = Game.Content.Load<Texture2D>("Cursor");
        }

        public override void Update(GameTime gameTime)
        {
            MouseState mouseState = Mouse.GetState();
            this.MousePosition = new Vector2(mouseState.X, mouseState.Y);
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            MouseBatch.Begin(SpriteBlendMode.AlphaBlend);
            MouseBatch.Draw(MouseTexture, this.MousePosition, Color.White);
            MouseBatch.End();
            base.Draw(gameTime);
        }
    }
}